<div id="mySubView">

<?php
$this->widget('zii.widgets.grid.CGridView', array(
	'dataProvider' => $dataprovider,
	'id'=>'recipient_table',
        'selectionChanged'=>'updateEditForm',
	'columns' => array(
                array(
                    'value'=>'$data[\'tbl_organisation_org_childid\']',
                    'type'=>'raw',
                    'htmlOptions'=>array(
                            'style'=>'width:30px',
                            'class'=>'org_id',
                            'onClick'=>"jQuery.ajax({'type':'POST','url':'".Yii::app()->createUrl('//kommunikation/dynamickommunikation')."','data':{'org_id':$(this).text()},'success':function(html){jQuery('#OrganisationHasTblOrganisation_kom_id').html(html)}});",
                    ),
                    'name'=>'O',
                ),array(
                    'value'=>'$data[\'kom_id\']',
                    'type'=>'raw',
                    'htmlOptions'=>array(
                            'style'=>'width:25px',
                            'onClick'=>"jQuery.ajax({'type':'POST','url':'".Yii::app()->createUrl('//kommunikation/dynamickommunikation')."','data':{'org_id':$(this).parent().children('.org_id').text()},'success':function(html){jQuery('#OrganisationHasTblOrganisation_kom_id').html(html)}});",
                    ),
                    'name'=>'K',
                ),
                array(
                    'value'=>'$data[\'tbl_organisation_org_id\']',
                    'type'=>'raw',
                    'htmlOptions'=>array(
                            'style'=>'width:25px',
                            'onClick'=>"jQuery.ajax(
                                {'type':'POST','url':'".Yii::app()->createUrl('//kommunikation/dynamickommunikation')."',
                                 'data':{'org_id':$(this).parent().children('.org_id').text()},
                                 'success':function(html){jQuery('#OrganisationHasTblOrganisation_kom_id').html(html)}});",
                    ),
                    'name'=>'P',
                ),
                array(
                    'value'=>'$data[\'tblOrganisationOrgChild\'][\'nachname\']',
                    'type'=>'raw',
                    'htmlOptions'=>array(
                            'onClick'=>"jQuery.ajax({'type':'POST','url':'".Yii::app()->createUrl('//kommunikation/dynamickommunikation')."','data':{'org_id':$(this).parent().children('.org_id').text()},'success':function(html){jQuery('#OrganisationHasTblOrganisation_kom_id').html(html)}});",
                    ),
                    'name'=>'Name',
                ),
                array(
                    'value'=>'$data[\'tblOrganisationOrgChild\'][\'vorname\']',
                    'type'=>'raw',
                    'htmlOptions'=>array(
                            'onClick'=>"jQuery.ajax({'type':'POST','url':'".Yii::app()->createUrl('//kommunikation/dynamickommunikation')."','data':{'org_id':$(this).parent().children('.org_id').text()},'success':function(html){jQuery('#OrganisationHasTblOrganisation_kom_id').html(html)}});",
                    ),
                    'name'=>'Christian Name'
                ),
                array(
                    'class'=>'CButtonColumn',
                    'template'=>'{delete}',
                    'deleteButtonUrl'=>'Yii::app()->createUrl("//organisation/childdelete", array("id" => $data[\'tbl_organisation_org_childid\'],"pid" => $data[\'tbl_organisation_org_id\'],"kom_id" => $data[\'kom_id\']))',
                ),      
            ),
          ));

?>

    <div id="mySubViewForm">

    <?php 
    
    $submodel = new OrganisationHasTblOrganisation();
    $submodel->tbl_organisation_org_id = $tbl_organisation_org_id;
    $this->renderPartial('organisationlink', array('model'=>$submodel));

    ?>

    </div>

</div>

<script type="text/javascript">

function updateEditForm(target_id){

    $('#Notification').jnotifyAddMessage({
	        text: 'Loading recipient...',
	        permanent: false,
	        showIcon: true
    });

    var id =$.fn.yiiGridView.getSelection(target_id);

    $('#rec_save_button').attr('value', (id != "" ? 'update' : 'create'));

    $.getJSON('<?php echo Yii::app()->createUrl("//organisation/subviewload"); ?>'+'&id='+id,
			function(data) {
				$('#sub_tbl_organisation_org_childid').val(data.nachname);
                                $('#OrganisationHasTblOrganisation_tbl_organisation_org_childid').val(data.tbl_organisation_org_childid);
                                $('#OrganisationHasTblOrganisation_tbl_organisation_org_id').val(data.tbl_organisation_org_id);
                                $('#OrganisationHasTblOrganisation_kom_id').val(data.kom_id);
                                $('#tbl_organisation_new').val("0");
			});

   return false;
}

</script>
